package com.bk.service;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.bk.entity.UserInfo;
import com.bk.mapper.UserLoginMapper;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class UserLoginService {

	@Autowired
	private UserLoginMapper userLoginMapper;
	
	@Resource
	RestTemplate restTemplate;
	public UserInfo getUserInfo(String CardId,String password) {
		UserInfo userInfo = userLoginMapper.selectByCardIdAndUpassword(CardId,password);
		return userInfo;
	}
	
	
	@HystrixCommand(fallbackMethod="helloFail")
	public String getHello(String name) {
		String url = "http://bk-employee/hello?name=" + name;
		return restTemplate.getForObject(url, String.class);
	}
	
	public String helloFail(String name){
		return "服务已宕机。。。";
	}
}
